package com.dyz.LeetCodeforSwordFingerOffer;

public class IsSymmetric28 {
    public boolean isSymmetric(TreeNode root) {
        if(root==null){
            return true;
        }

        return dfs(root.left, root.right);

    }

    private boolean dfs(TreeNode left, TreeNode right){
        //终止条件
        if(left==null || right==null){
            return left==right;
        }
        //判断条件
        if(left.val!=right.val){
            return false;
        }
        //深度递归
        return dfs(left.left, right.right) && dfs(left.right, right.left);
    }
}
